<?php

namespace Modules\Admin\Http\Controllers\Categories;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Common\General\Security\Api\Gateway;
use Modules\Common\Models\AdminLog;
use Modules\Common\Models\Categories;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;


class Update
{

    /**
     * @Route(path=/api/admin/category  method=put)
     */
    public function index()
    {
        Api::validate(['id' => 'required|integer']);
        $id = request('id');
        $adminUserIdDefault = auth('api')->user()->id;
        $eidDefault = auth('api')->user()->eid; 
        $sidDefault = auth('api')->user()->sid;
        Categories::updateFromArray([
            'id' => $id,
            'category_name' => request('category_name'),
            'parentid' => request('parentid'),
            'is_enabled' => request('is_enabled'),
            'admin_user_id'=>$adminUserIdDefault,
            'eid'=>$eidDefault,
            'sid'=>$sidDefault,
            'updated_at'=>date('Y-m-d H:i:s')
        ]);
        return Api::success();
    }
}